# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer:
pkgname=polyml
pkgver=5.8.1
pkgrel=0
pkgdesc="ML97 compatible Standard ML implementation"
url="https://www.polyml.org/"
arch="all !aarch64 !ppc64le !s390x !mips !mips64"
license="LGPL-2.1-only"
makedepends="gmp-dev libffi-dev"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/polyml/polyml/archive/v$pkgver.tar.gz
	"

# FIXME: https://github.com/polyml/polyml/issues/110
case "$CARCH" in
	armhf|armv7) options="!check" ;;
esac

build() {
	# Compiling poly as a dynamically linked position independent
	# executable causes it to segfault. Since Alpine's GCC enables
	# PIE by default we need to explicitly disable it.
	CFLAGS="$CFLAGS -no-pie" ./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--with-system-libffi \
		--with-gmp
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="8701c27a4a84b00529b8ae30ce340a46f45eb12d74a94ff5c5663bbbe79f5723039b96298190ba23bcbde11a26fb2b364d9452f45fdb19576a596e364812416f  polyml-5.8.1.tar.gz"
